//
//  ShouCangLianXiDingDan.swift
//  RoundCatPlay2
//
//  Created by 姜澎 on 2019/10/30.
//  Copyright © 2019 jiangpeng. All rights reserved.
//

import UIKit

class ShouCangLianXiDingDan: UIView {
    
    
    private lazy var showBtu: UIImageView = {
        let i = UIImageView()
        i.image = UIImage(named: "收藏")
        return i
    }()
    
    private lazy var showLable: UILabel = {
        let l = UILabel()
        l.text = "收藏"
        l.font = UIFont.systemFont(ofSize: 15)
        return l
    }()
    
    private lazy var rightLine: UIView = {
        let v = UIView()
        v.backgroundColor = UIColor(red: 229.0 / 255.0, green: 229.0 / 255.0, blue: 229.0 / 255.0, alpha: 1.0)
        return v
    }()
    
    
    private lazy var showView: UIView = {
        let v = UIView()
        v.addSubview(self.showBtu)
        v.addSubview(self.showLable)
        v.addSubview(self.rightLine)
        
        return v
    }()
    
    
    private lazy var messgeImage: UIImageView = {
        let i = UIImageView()
        i.image = UIImage(named: "message")
        return i
    }()
    
    private lazy var messageLable: UILabel = {
        let l = UILabel()
        l.text = "联系TA"
        l.font = UIFont.systemFont(ofSize: 15)
        return l
    }()
    
    private lazy var Lianxi: UIView = {
        let v = UIView()
        v.addSubview(self.messgeImage)
        v.addSubview(self.messageLable)
        return v
    }()
    
    private lazy var dingDan: UIButton = {
        let but = UIButton(type: .custom)
        but.backgroundColor = UIColor(red: 83.0 / 255.0, green: 105.0 / 255.0, blue: 237.0 / 255.0, alpha: 1.0)
        but.setTitle("立即下单", for: .normal)
        but.setTitle("立即下单", for: .highlighted)
        but.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        return but
    }()
    

    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

}

extension ShouCangLianXiDingDan {
    func setUI() {
        addSubview(showView)
        addSubview(Lianxi)
        addSubview(dingDan)
        
        
        
        setShowViewFrame()
        setLianxiViewFrame()
        setdingDanButFrame()
        
        setShowBut()
        setShowLable()
        setRightLine()
        
        setMessageImageFrame()
        setMessageLableFrame()
    }
    
    func setShowViewFrame() {
        self.showView.snp.makeConstraints { (make) in
            make.top.equalTo(0)
            make.bottom.equalTo(0)
            make.left.equalTo(0)
            make.right.equalTo(Lianxi.snp.left)
            make.height.equalTo(49)
            make.width.equalTo(Lianxi.snp_width)
        }
    }
    
    func setLianxiViewFrame() {
        self.Lianxi.snp.makeConstraints { (make) in
            make.top.equalTo(0)
            make.bottom.equalTo(0)
            make.right.equalTo(dingDan.snp_left)
            make.height.equalTo(showView.snp_height)
            make.width.equalTo(dingDan.snp_width)
        }
    }
    
    func setdingDanButFrame() {
        self.dingDan.snp.makeConstraints { (make) in
            make.top.equalTo(0)
            make.bottom.equalTo(0)
            make.right.equalTo(0)
            make.height.equalTo(showView.snp_height)
    
        }
    }
    
    func setShowBut(){
        self.showBtu.snp.makeConstraints { (make) in
            make.top.equalTo(14)
            make.left.equalTo(26)
            make.width.equalTo(22)
            make.height.equalTo(22)
            make.bottom.equalTo(-14)

            
        }
    }
    
    func setShowLable() {
        self.showLable.snp.makeConstraints { (make) in
            make.top.equalTo(self.showBtu.snp_top).offset(4)
            make.left.equalTo(showBtu.snp_right).offset(10)
        }
    }
    
    func setRightLine() {
        self.rightLine.snp.makeConstraints { (make) in
            make.top.equalTo(14)
            make.bottom.equalTo(-14)
            make.width.equalTo(1)
            make.right.equalTo(0)
        }
    }
    
    func setMessageImageFrame() {
        self.messgeImage.snp.makeConstraints { (make) in
            make.top.equalTo(16)
            make.left.equalTo(26)
            make.bottom.equalTo(-16)
            make.width.equalTo(22)
            make.height.equalTo(18)
        }
    }
    
    func setMessageLableFrame() {
        self.messageLable.snp.makeConstraints { (make) in
            make.top.equalTo(self.messgeImage.snp_top)
            make.left.equalTo(self.messgeImage.snp_right).offset(10)
        }
    }
    
}
